package com.runfast.waimai.util;


import com.runfast.waimai.dao.model.RunfastGoodsSell;
import com.runfast.waimai.dao.model.RunfastGoodsSellRecord;
import org.json.JSONArray;
import org.json.JSONObject;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyUtil {
	
	private static final double EARTH_RADIUS = 6371000;
	private static final String[] chars = { "0", "1", "2", "3", "4", "5", "6","7", 
		"8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J","K", "L","M", "N","O",
		"P", "Q", "R", "S", "T", "U","V", "W", "X", "Y", "Z", "a", "b", "c", "d",
		 "e", "f", "g", "h", "i", "j", "k", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
		 "w", "x", "y", "z" };
	
	private static final String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
    private static final String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
    private static final String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
    private static final String regEx_space = "\\s*|\t|\r|\n";//定义空格回车换行符
    private static final String ak2 = "BrbDrmC3GyIBRExpp5jXF0HpcXcP9P5v";//百度AK
//    private static final String ak = "jxL9ZCE1KGypzG1MbPwSSAcR";//百度AK
    private static final String ak = "BrbDrmC3GyIBRExpp5jXF0HpcXcP9P5v";//百度AK
    
	private static final String gaoDekey = "f2d9f1f42e56a8e5ddf9b3a1b669f3b9";
	//final String gaoDe
	
    
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    private static SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
	/**
	 * 设置时间为该天的结束时间：yyyy-MM-dd 23:59:59
	 * */
	public static Date getEndDay(Date time){
		
		Calendar cl = Calendar.getInstance();
		cl.setTime(time);
		cl.set(Calendar.HOUR_OF_DAY, 23);
		cl.set(Calendar.MINUTE, 59);
		cl.set(Calendar.SECOND, 59);
		return cl.getTime();
	}
	/**
	 * 设置时间为该天的开始时间：yyyy-MM-dd 00:00:00
	 * */
	public static  Date getStartDay(Date time){
		
		Calendar cl = Calendar.getInstance();
		cl.setTime(time);
		cl.set(Calendar.HOUR_OF_DAY, 0);
		cl.set(Calendar.MINUTE, 0);
		cl.set(Calendar.SECOND, 0);
		return cl.getTime();
	}
	/**
	 * 找出给出时间的前几天记录
	 * @param time   
	 * @param beforeDay 前？天
	 * @return
	 */
	public static Date getBeforeDay(Date time,Integer beforeDay) {
		Calendar cl = Calendar.getInstance();
		cl.setTime(time);
		cl.set(Calendar.HOUR_OF_DAY, 0);
		cl.set(Calendar.MINUTE, 0);
		cl.set(Calendar.SECOND, 0);
		cl.add(Calendar.DAY_OF_MONTH, beforeDay);
		return cl.getTime();
		
	}
	/**
	 * 获取给出时间的当月第一天
	 * @param time
	 * @return
	 */
	public static Date getMonthStartDate(Date time){
		Calendar cl = Calendar.getInstance();
		cl.setTime(time);
		cl.set(Calendar.DAY_OF_MONTH, 1);
		return getStartDay(cl.getTime());
	}
	/**
	 * 获取给出时间的当月最后一天
	 * @param time
	 * @return
	 */
	public static Date getMonthEendDate(Date time){
		Calendar cl = Calendar.getInstance();
		cl.setTime(time);
		cl.add(Calendar.MONTH, 1);
		cl.set(Calendar.DAY_OF_MONTH, 0);
		return getEndDay(cl.getTime());
	}
	
	
	/**
	 * 获取当前时间的当月第一天
	 * param time
	 * @return
	 */
	public static Date getnowMonthStartDate(){
		Calendar cl = Calendar.getInstance();
		cl.set(Calendar.DAY_OF_MONTH, 1);
		return getStartDay(cl.getTime());
	}
	/**
	 * 获取给出时间的当月最后一天
	 * param time
	 * @return
	 */
	public static Date getnowMonthEendDate(){
		Calendar cl = Calendar.getInstance();
		cl.add(Calendar.MONTH, 1);
		cl.set(Calendar.DAY_OF_MONTH, 0);
		return getEndDay(cl.getTime());
	}
	/**
     * 隐藏电话号码中间4位
     * @param phone
     * */
    public static String ellipsizePhone(String phone){
    	String newPhone = phone;
    	if(phone!=null&&phone.length()>=11){//13768273510
    		newPhone = phone.substring(0,3)+"****"+phone.substring(7);
    	}
    	return newPhone;
    }
    /**
     * 获取随机字符
     * */
    public static String randomChar(int size){
    	StringBuffer sb = null;
    	if(size>0){
    		sb = new StringBuffer();
    		Random ran = new Random();
    		for(int i = 1; i <= size; i++ ){
    			int r = ran.nextInt(chars.length);
    			sb.append(chars[r]);
    		}
    	}
		return sb.toString();
    }
    /**
     * 获取随机数
     * */
    public static String randomNumber(int size){
    	StringBuffer sb = null;
    	if(size>0){
    		sb = new StringBuffer();
    		Random ran = new Random();
    		for(int i = 1; i <= size; i++ ){
    			int r = ran.nextInt(10);
    			sb.append(r);
    		}
    	}
		return sb.toString();
    }
	public static void main(String[] args) {
		/*String str="0001";
		String result = ""+(Integer.parseInt(str)+1);
		System.out.println(str+";"+result);
		int size = 3-result.length();
		for(int j=0;j<size;j++){
		result="0"+result;
		}
		System.out.println(result);*/
		String ordercode="wewew'223\"35";
		System.out.println(ordercode.substring(6,ordercode.length()));
//		if(!ComUtil.isEmpty(ordercode)){
//			String order=ordercode.substring(ordercode.length()-4);
//			int x=9999;
//			try{
//				 x=Integer.parseInt(order)+1;
//				System.out.println(x);
//			}catch (Exception e){
//				//System.out.println(e.getMessage());
//			}
//		   
//		}
		
		//getAdd(116.30815, 40.056885 ,1);
		/*Pattern pattern = Pattern.compile("[0-9]*"+"路;"); 
	   Matcher isNum = pattern.matcher("11路；69路");
	   if(isNum.matches() ){
	      System.out.println(11111);
	   } */
		//getAddress(108.357882,22.797472);
		//getTodayWeather("南宁");
//		findByKey("桂平市世纪名门","贵港市", 30, 1);
//		gettext("13812345678","e10adc3949ba59abbe56e057f20f883e");

		Map<String, Double> map = transformLngLatToBaidu(114.32654274317045,30.6161891569991);
		System.out.println(""+map.get("lng")+","+map.get("lat"));
	}

	 public static List<Map<String, Object>> gettext(String mobile,String password){  
		  	String res = "";
			String urlString = "http://pay.gxptkc.com/business/api/loadstatrders.do";  
			
			List<Map<String, Object>> poisList = new ArrayList<Map<String,Object>>();
			try
			
			{
				HttpBase httpBase = new HttpBase(urlString);
				
				httpBase.setCharset("UTF-8");
				httpBase.addParam("mobile", mobile);
				httpBase.addParam("password", password);
				httpBase.post();
				res = httpBase.getResponseText();
				
			//使用http请求获取转换结果

		

			} catch (Exception e)

			{

			e.printStackTrace();

			}
			
	        return poisList;    
	    }  
	/**
	 * 根据经纬度获取两点之间的距离
	 * @param longitude1
	 * @param latitude1
	 * @param longitude2
	 * @param latitude2
	 * @return
	 */
//	---------------------------------------------------------------------------------
	/*
	* 高德计算两点之间距离
	* 2018/7/14 mengxiang
	* */
	public static double getDistance(double latitude1,double longitude1,
							 double latitude2, double longitude2)
	{

		double lon1 = (Math.PI / 180) * longitude1;
		double lon2 = (Math.PI / 180) * longitude2;
		double lat1 = (Math.PI / 180) * latitude1;
		double lat2 = (Math.PI / 180) * latitude2;

		// double Lat1r = (Math.PI/180)*(gp1.getLatitudeE6()/1E6);
		// double Lat2r = (Math.PI/180)*(gp2.getLatitudeE6()/1E6);
		// double Lon1r = (Math.PI/180)*(gp1.getLongitudeE6()/1E6);
		// double Lon2r = (Math.PI/180)*(gp2.getLongitudeE6()/1E6);

		// 地球半径
		double R = 6371;

		// 两点间距离 km，如果想要米的话，结果*1000就可以了
		double d = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R;

		return d * 1000;
	}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	// 返回单位是米
//	 public static double getDistance1(double longitude1, double latitude1,
//	  double longitude2, double latitude2) {
//		  double Lat1 = rad(latitude1);
//		  double Lat2 = rad(latitude2);
//		  double a = Lat1 - Lat2;
//		  double b = rad(longitude1) - rad(longitude2);
//		  /*double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
//		    + Math.cos(Lat1) * Math.cos(Lat2)
//		    * Math.pow(Math.sin(b / 2), 2)));*/
//		  double s = Math.acos(Math.cos(Lat1)*Math.cos(Lat2)*Math.cos(b)+Math.sin(Lat1)*Math.sin(Lat2));
//		  s = s * EARTH_RADIUS;
////		 String dis=new DecimalFormat("0.00").format(s);
////		 System.out.println("####getDistance#### "+dis);
//
////		  s = Math.round(s * 10000) / 10000;
////		  return Double.valueOf(dis);
//		 return s;
//	 }

	 private static double rad(double d) {  
		  return d * Math.PI / 180.0;  
		 }
	 
	 /**
	  * 将给定的经纬度转换为百度经纬度
	  * @param lng
	  * @param lat
	  * @return
	  */
	 public static Map<String,Double> transformLngLatToBaidu(Double lng,Double lat) {
	       Map<String,Double> newInfo = new HashMap<String, Double>();
	       /*BaiduWebIp b = new BaiduWebIp();
	       String result = b.transform(lng,lat);
	       if(!ComUtil.isEmpty(result)){
				JSONObject jsonObj;
				try {
					jsonObj = new JSONObject(result);
					if(jsonObj != null){
						if(jsonObj.optInt("status") == 0){ //正常是返回0
							JSONArray infoArr = jsonObj.getJSONArray("result");
							if(infoArr != null ){
								JSONObject obj =infoArr.getJSONObject(0);
								//System.out.println("x=" + ComUtil.getDouble(obj.optString("x")) +"   y=" + ComUtil.getDouble(obj.optString("y")));
								newInfo.put("lng", ComUtil.getDouble(obj.optString("x")));
								newInfo.put("lat", ComUtil.getDouble(obj.optString("y")));
							}
						}
					}
				} catch (JSONException e) {
					e.printStackTrace();
				}
	       }*/
		 double[] doubles = GPSUtil.gps84_To_bd09(lat, lng);
		 newInfo.put("lng", doubles[1]);
		 newInfo.put("lat", doubles[0]);
	        return newInfo;
	    }


	/**
	 * 将高德经纬度转化为百度经纬度
	 * @param lng
	 * @param lat
	 * @return
	 */
	public static Map<String,Double> transformAmapToBaidu(Double lng,Double lat) {
		Map<String,Double> newInfo = new HashMap<String, Double>();

		double[] doubles = GPSUtil.gcj02_To_Bd09(lat, lng);
		newInfo.put("lng", doubles[1]);
		newInfo.put("lat", doubles[0]);
		return newInfo;
	}
	 public static String getUrl(HttpServletRequest request){
			StringBuffer originalURL = request.getRequestURL();
			Map parameters = request.getParameterMap();
	        if (parameters != null && parameters.size() > 0) {
	            originalURL.append("?");
	            Iterator iter = parameters.keySet().iterator(); 
	            while (iter.hasNext()) {
	                String key = (String) iter.next();
	                String[] values = (String[]) parameters.get(key);
	                for (int i = 0; i < values.length; i++) {
	                    originalURL.append(key).append("=").append(values[i]);
	                    if(i != values.length-1){
	                    	originalURL.append("&");
	                    }
	                }
	                if(iter.hasNext()){
	                	originalURL.append("&");
	                }
	            }
	        }
	        return originalURL.toString();
		}
	 
	 public static String getOrderCode(){
			//首先，Math.random()取值范围是[0,1)
			//那么Math.random()*9000的取值范围是[0,9000);
			//那么Math.random()*9000+1000的取值范围是[1000,10000)。
			StringBuffer sbf = new StringBuffer();
			sbf.append("w");
			
			 Date dt= new Date();
			 
	    	 Long longtime= dt.getTime();//这就是距离1970年1月1日0点0分0秒的毫秒数
	    	 Integer random =  (int) (Math.random()*9000+1000);//
	    	 return sbf.append(ComUtil.getDate("yyyyMMdd")).toString();
		}
	 
	 /**
	  * 根据经纬度获取百度位置
	  * @param log
	  * @param lat
	  * @param pois 是否显示周边  0：不显示 1：显示
 	  * @return
	  */
	 public static List<Map<String, Object>> getAdd(Double log, Double lat ,int pois){  
		  	String res = "";
			String urlString = "http://api.map.baidu.com/geocoder/v2/" +
    		"?ak="+ak+"&callback=renderReverse&" +
    		"location="+lat+","+log+"&output=json&pois="+pois;  
			
			List<Map<String, Object>> poisList = new ArrayList<Map<String,Object>>();
			try
			
			{
				HttpBase httpBase = new HttpBase(urlString);
				httpBase.get();
				httpBase.setCharset("UTF-8");
				
				res = httpBase.getResponseText();
				
			//使用http请求获取转换结果

			if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

				String str = res.substring(res.indexOf("(") + 1, res.length()-1);
				
	
				String err = res.substring(res.indexOf("status") + 8, res.indexOf("status") + 9);
				
				if ("0".equals(err)){
					
				
				
				//编码转换
				
					int start =0;
					int end = 0;	
					if(str.indexOf("pois")!=-1){
						start = str.indexOf("pois");
					}
					if(str.indexOf("]")!=-1){
						end = str.indexOf("]");
					}
					//System.out.println(str.substring(start+6, end+1));
					str = str.substring(start+6, end+1);//附近地址数组
					JSONArray jsonArray = new JSONArray(str);
					//String city =(String) ((JSONObject)jsonArray.get(i)).opt("city");
					for(int i=0 ;i<jsonArray.length(); i++){
						
						String name =(String) ((JSONObject)jsonArray.get(i)).opt("name");
						String addr =(String) ((JSONObject)jsonArray.get(i)).opt("addr");
						
						JSONObject obj = ((JSONObject)jsonArray.get(i)).optJSONObject("point");
						
						Double latitude = obj.getDouble("y");
						Double longitude =  obj.getDouble("x");
						
						//System.out.println(name +":"+addr +"longitude="+obj.get("x")+"latitude="+obj.get("y"));
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("name", name);
						map.put("content", addr);
						map.put("latitude", latitude);
						map.put("longitude", longitude);
						
						poisList.add(map);
					}
					
				}

			}

			} catch (Exception e)

			{

			e.printStackTrace();

			}
			
	        return poisList;    
	    }  
	 
	 /**
	  *  根据关键字获取城市周边的地址、建筑物
	  * @param keyword 关键字
	  * @param area 地区 如：南宁
	  * @param pageSize 数量
	  * @param page 页数
	  * @return
	  */
	 public static List<Map<String, Object>> findByKey(String keyword, String area ,Integer pageSize , Integer page){  

		 	List<Map<String, Object>> list =new ArrayList<Map<String,Object>>();
		
	        String urlString = "http://api.map.baidu.com/place/search?query="+
						        keyword+"&page_size"+pageSize+"&page_num="+page+"&scope=1&region="+
						        area+"&output=json&ak="+ak+"";  
	       
	        String res = "";     
	    	HttpBase httpBase = new HttpBase(urlString);
			httpBase.get();
			httpBase.setCharset("UTF-8");
			
			res = httpBase.getResponseText();
	        try {     
	        	 
				//使用http请求获取转换结果

			//	if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

					String err = res.substring(res.indexOf("status") + 9, res.indexOf("status") + 11);
					
					if ("OK".equals(err)){
						
					
					
						//编码转换
						
						int start =0;
						int end = 0;
						if(res.indexOf("results")!=-1){
							start = res.indexOf("results");
						}
						if(res.indexOf("]")!=-1){
							end = res.indexOf("]");
						}
					
						//System.out.println(res.substring(start+9, end+1));
						res = res.substring(start+9, end+1);//附近地址数组
						
						
					JSONArray jsonArray = new JSONArray(res);
						for(int i=0 ;i<jsonArray.length(); i++){
							
							String name =(String) ((JSONObject)jsonArray.get(i)).opt("name");
							String addr =(String) ((JSONObject)jsonArray.get(i)).opt("address");
							
							JSONObject obj = ((JSONObject)jsonArray.get(i)).optJSONObject("location");
							
							Double latitude = obj.getDouble("lat");
							Double longitude =  obj.getDouble("lng");
							
							
							Map<String, Object> map = new HashMap<String, Object>();
							map.put("name", name);
							map.put("content", addr);
							map.put("latitude", latitude);
							map.put("longitude", longitude);
							
							list.add(map);
						}
						
					}

				
	        	
	        	
	        } catch (Exception e) {    
	            System.out.println("error in wapaction,and e is " + e.getMessage());    
	        }   
	        
	        return list;    
	    }  
	 /**
	  * 根据经纬度获取百度位置
	  * @param log
	  * @param lat
 	  * @return
	  */
	 public static Map<String, Object> getAddress(Double log, Double lat ){  
		  	String res = "";
			String urlString = "http://api.map.baidu.com/geocoder/v2/" +
    		"?ak="+ak+"&callback=renderReverse&" +
    		"location="+lat+","+log+"&output=json";  
			Map<String, Object> map = new HashMap<String,Object>();
			try
			
			{
				HttpBase httpBase = new HttpBase(urlString);
				httpBase.get();
				httpBase.setCharset("UTF-8");
				
				res = httpBase.getResponseText();
				
			//使用http请求获取转换结果

			if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

				String str = res.substring(res.indexOf("(") + 1, res.length()-1);
				
	
				String err = res.substring(res.indexOf("status") + 8, res.indexOf("status") + 9);
				
				if ("0".equals(err)){
					
				
				
				//编码转换
					
					int start =0;
					int end = 0;
					if(res.indexOf("results")!=-1){
						start = res.indexOf("results");
					}
					if(res.indexOf("]")!=-1){
						end = res.indexOf("]");
					}
					//str = str.substring(start+6, end+1);//附近地址数组
					res = res.substring(start+9, end+1);//附近地址数组
					
					JSONObject json=new JSONObject(str);
					JSONObject jsonObj=json.getJSONObject("result");
					//JSONObject jsonObj = new JSONObject(str);
					
					//JSONObject poiRegions =(JSONObject) jsonObj.optJSONObject("poiRegions");
					JSONObject addressComponent =(JSONObject) jsonObj.optJSONObject("addressComponent");
					//String name=poiRegions.optString("name");
						//JSONObject addjsonObj = new JSONObject(addressComponent);
						String formatted_address =(String) jsonObj.optString("sematic_description");
						String province=(String)addressComponent.optString("province");
						//int leng=province.length();
					//	formatted_address=formatted_address.replace(province, "");
						String regex="(附近)";
						String regex2="(米)";
						Matcher matcher = Pattern.compile(regex).matcher(formatted_address);
						if(matcher.find()){
							int start1 = formatted_address.indexOf("附近");
							String address2=formatted_address.substring(start1);
							Pattern p = Pattern.compile(".*\\d+.*");
							Matcher m = p.matcher(address2);
							Matcher m2 = Pattern.compile(regex2).matcher(address2);
							if(m.matches()&&m2.find()){
								formatted_address=formatted_address.substring(0,start1);
								//System.out.println("formatted_address="+formatted_address);
							}
							
							
						} 
						String city=(String)addressComponent.optString("city");
						
						String district=(String)addressComponent.optString("district");
						//formatted_address=district+formatted_address;
						map.put("province", province);
						map.put("city", city);
						map.put("countyName", district);
						map.put("address", district);
						//map.put("name", name);
						map.put("latitude", lat);
						map.put("longitude", log);
				}

			}

			} catch (Exception e)

			{

			e.printStackTrace();

			}
			
	        return map;    
	    }
		/**
		 * 获取给出时间的小时
		 * @param date
		 * @return
		 */
		public static int getHour(Date date){
			int hour=0;
			Calendar cl = Calendar.getInstance();
			cl.setTime(date);
			hour=cl.get(Calendar.HOUR_OF_DAY);
			return hour;
		}
		/**
		 * 时间 date 是否在date1 ，date2之间
		 * @param date
		 * @param beginTime
		 * @param endTime
		 * @return
		 */
		public static boolean inTime(Date beginTime,Date endTime,Date date){
			
			boolean after = false;
			Calendar curDate = Calendar.getInstance();
			curDate.setTime(date);
			long d=curDate.getTimeInMillis();
			//int hour=curDate.get(Calendar.HOUR_OF_DAY);
			Calendar cal=Calendar.getInstance();
			
			cal.setTime(endTime);
			
			int endour=cal.get(Calendar.HOUR_OF_DAY);
			int min=cal.get(Calendar.MINUTE);
			curDate.set(Calendar.HOUR_OF_DAY, endour);
			curDate.set(Calendar.MINUTE, min);
			long d2=curDate.getTimeInMillis();
			
			cal.setTime(beginTime);
			// hour=cal.get(Calendar.HOUR_OF_DAY);
			 int beginour=cal.get(Calendar.HOUR_OF_DAY);
			 min=cal.get(Calendar.MINUTE);
			curDate.set(Calendar.HOUR_OF_DAY, beginour);
			curDate.set(Calendar.MINUTE, min);
			long d1=curDate.getTimeInMillis();
			
			
		
			
			
			
			if(d>=d1&&d<=d2){
				after = true;
			}

			if(beginTime.after(endTime)){
				if(d>=d1||d<=d2){
					after = true;
				}
			}
			return after;
		}
		/**
		 * 计算2个经纬度之间的距离
		 */
		public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
		  {
		     double radLat1 = rad(lat1);
		     double radLat2 = rad(lat2);
		     double a = radLat1 - radLat2;
		     double b = rad(lng1) - rad(lng2);
		     double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
		      Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
		     s = s * EARTH_RADIUS;
		     s = Math.round(s * 10000) / 10000;
		     return s;
		  }
		
	
	    
		/**
		 * 
		 * 获取实时天气2<br>
		 * 方 法 名： getTodayWeather <br>
		 * 
		 * param Cityid
		 *            城市编码
		 */
	    		 public static Map<String, Object> getTodayWeather(String cityName ){  
	    			  	String res = "";
	    			  	
//	    				String urlString = "http://api.map.baidu.com/geocoder/v2/" +
//	    	    		"?ak="+ak+"&callback=renderReverse&" +
//	    	    		"location="+lat+","+log+"&output=json";  
	    				Map<String, Object> map = new HashMap<String,Object>();
	    				try
	    				
	    				{
	    					String	urlString = "http://api.map.baidu.com/telematics/v3/weather?location="+URLEncoder.encode(cityName, "utf-8")+"&output=json&ak="+ak+"";
	    					HttpBase httpBase = new HttpBase(urlString);
	    					httpBase.get();
	    					httpBase.setCharset("UTF-8");
	    					
	    					res = httpBase.getResponseText();
	    					
	    				//使用http请求获取转换结果
//	    					{"error":0,"status":"success","date":"2016-09-22","results":[
//	    					{"currentCity":"南宁","pm25":"107","index":[{"title":"穿衣","zs":"炎热","tipt":"穿衣指数","des":"天气炎热，建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。"},
//	    					{"title":"洗车","zs":"较适宜","tipt":"洗车指数","des":"较适宜洗车，未来一天无雨，风力较小，擦洗一新的汽车至少能保持一天。"},
//	    					{"title":"旅游","zs":"较适宜","tipt":"旅游指数","des":"天气较好，温度较高，天气较热，但有微风相伴，还是比较适宜旅游的，不过外出时要注意防暑防晒哦！"},
//	    					{"title":"感冒","zs":"少发","tipt":"感冒指数","des":"各项气象条件适宜，发生感冒机率较低。但请避免长期处于空调房间中，以防感冒。"},
//	    					{"title":"运动","zs":"较适宜","tipt":"运动指数","des":"天气较好，户外运动请注意防晒。推荐您进行室内运动。"},
//	    					{"title":"紫外线强度","zs":"中等","tipt":"紫外线强度指数","des":"属中等强度紫外线辐射天气，外出时建议涂擦SPF高于15、PA+的防晒护肤品，戴帽子、太阳镜。"}],
//	    					"weather_data":[
//	    					{"date":"周四 09月22日 (实时：25℃)","dayPictureUrl":"http://api.map.baidu.com/images/weather/day/duoyun.png","nightPictureUrl":"http://api.map.baidu.com/images/weather/night/duoyun.png","weather":"多云","wind":"东北风微风","temperature":"33 ~ 24℃"},
//	    					{"date":"周五","dayPictureUrl":"http://api.map.baidu.com/images/weather/day/duoyun.png","nightPictureUrl":"http://api.map.baidu.com/images/weather/night/duoyun.png","weather":"多云","wind":"东风微风","temperature":"33 ~ 25℃"},
//	    					{"date":"周六","dayPictureUrl":"http://api.map.baidu.com/images/weather/day/zhenyu.png","nightPictureUrl":"http://api.map.baidu.com/images/weather/night/zhenyu.png","weather":"阵雨","wind":"东南风微风","temperature":"32 ~ 25℃"},
//	    					{"date":"周日","dayPictureUrl":"http://api.map.baidu.com/images/weather/day/zhenyu.png","nightPictureUrl":"http://api.map.baidu.com/images/weather/night/duoyun.png","weather":"阵雨转多云","wind":"东南风微风","temperature":"31 ~ 25℃"}]}]}

	    				if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

	    					String str = res.substring(res.indexOf("(") + 1, res.length()-1);
	    					
	    		
	    					String err = res.substring(res.indexOf("error") + 7, res.indexOf("error") + 8);
	    					
	    					if ("0".equals(err)){
	    						
	    					
	    					
	    					//编码转换
	    						
	    						int start =0;
	    						int end = 0;
	    						if(res.indexOf("weather_data")!=-1){
	    							start = res.indexOf("weather_data");
	    						}
	    						if(res.indexOf("}]}")!=-1){
	    							end = res.indexOf("}]}");
	    						}
	    						//System.out.println(str.substring(start+6, end+1));
	    						//str = str.substring(start+6, end+1);//附近地址数组
	    						res = res.substring(start+14, end+2);//附近地址数组
	    						
	    						JSONArray jsonArray = new JSONArray(res);
	    						if(jsonArray.length()>0){
	    							String name =(String) ((JSONObject)jsonArray.get(0)).opt("weather");
	    							map.put("weather", name);
	    						}
	    						
	    					}

	    				}

	    				} catch (Exception e)

	    				{

	    				e.printStackTrace();

	    				}
	    				
	    		        return map;    
	    		    }
	    		 
	    			/*
	 			 * 过滤掉html标记
	 			 * */
	 		    public static String delHTMLTag(String htmlStr) {
	 		        Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
	 		        Matcher m_script = p_script.matcher(htmlStr);
	 		        htmlStr = m_script.replaceAll(""); // 过滤script标签

	 		        Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
	 		        Matcher m_style = p_style.matcher(htmlStr);
	 		        htmlStr = m_style.replaceAll(""); // 过滤style标签

	 		        Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
	 		        Matcher m_html = p_html.matcher(htmlStr);
	 		        htmlStr = m_html.replaceAll(""); // 过滤html标签

	 		        Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
	 		        Matcher m_space = p_space.matcher(htmlStr);
	 		        htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
	 		        return htmlStr.replaceAll("&nbsp;", "").trim(); // 返回文本字符串
	 		    }
	 			/**
	 			 * 是否当月1号
	 			 * param date
	 			 * @return
	 			 */
	 			public static boolean isFirstDay(Date time) {
	 				Calendar cl = Calendar.getInstance();
	 				cl.setTime(time);
	 				return cl.get(Calendar.DAY_OF_MONTH)==1? true:false;
	 			}
	 			/**
	 			 *根据经纬度查询所在城市
	 			 */
	 		public static String selectcity(Double log, Double lat ){
	 			String res = "";
	 			String sc ="";
				String urlString =  "http://api.map.baidu.com/geocoder/v2/?ak="+ak+""
						+ "&location="+lat+","+log+"&output=json&pois=1";
				HttpBase httpBase = new HttpBase(urlString);
				httpBase.get();
				httpBase.setCharset("UTF-8");
				
				res = httpBase.getResponseText();
	 			if(res!=null){
	 				int start =0;
					int end = 0;
					if(res.indexOf("city")!=-1){
						start = res.indexOf("city");
					}
					if(res.indexOf("district")!=-1){
						end = res.indexOf("district");
					}
					 sc = res.substring(start+7,end-3);
	 			}
			    
				return sc;
	 		} 
	 	   public static List<String> permutation(List<String> inputList){
			    List<String> resList = new ArrayList<String>();
			    permutationInt(inputList, resList, 0, new String[inputList.size()]);
			    return resList;
			}
	 	  public static void permutationInt(List<String> inputList, List<String> resList,
			        int ind, String[] arr) {
			    if(ind == inputList.size()){
			    	StringBuilder builder = new StringBuilder();
			    	for(int i=0;i<arr.length;i++){
			    		builder.append(arr[i]);
			    		if(i+1<arr.length){
			    			builder.append("-");
			    		}
			    	}
			        resList.add(builder.toString());
			        return;
			    }
			    for(String c: inputList.get(ind).replace("，", ",").split(",")){
		    		arr[ind] = c;
		    		permutationInt(inputList, resList, ind + 1, arr);
		    	
		    } 
    }
	 	 /**
			 *处理特殊‘符号
			 */
	 	 public static RunfastGoodsSellRecord replaceTag(RunfastGoodsSellRecord gr){
	 		if(gr!=null){
	 			if(!ComUtil.isEmpty(gr.getAddress())){
	 				gr.setAddress(gr.getAddress().replace("'", ""));
	 				gr.setAddress(gr.getAddress().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getActivityname())){
	 				gr.setActivityname(gr.getActivityname().replace("'", ""));
	 				gr.setActivityname(gr.getActivityname().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getAgentname())){
	 				gr.setAgentname(gr.getAgentname().replace("'", ""));
	 				gr.setAgentname(gr.getAgentname().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getBusinessaddr())){
	 				gr.setBusinessaddr(gr.getBusinessaddr().replace("'", ""));
	 				gr.setBusinessaddr(gr.getBusinessaddr().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getBusinessname())){
	 				gr.setBusinessname(gr.getBusinessname().replace("'", ""));
	 				gr.setBusinessname(gr.getBusinessname().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getContent())){
	 				gr.setContent(gr.getContent().replace("'", ""));
	 				gr.setContent(gr.getContent().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getCouponname())){
	 				gr.setCouponname(gr.getCouponname().replace("'", ""));
	 				gr.setCouponname(gr.getCouponname().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getGoodssellname())){
	 				gr.setGoodssellname(gr.getGoodssellname().replace("'", ""));
	 				gr.setGoodssellname(gr.getGoodssellname().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getShopper())){
	 				gr.setShopper(gr.getShopper().replace("'", ""));
	 				gr.setShopper(gr.getShopper().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getUseraddress())){
	 				gr.setUseraddress(gr.getUseraddress().replace("'", ""));
	 				gr.setUseraddress(gr.getUseraddress().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getUsername())){
	 				gr.setUsername(gr.getUsername().replace("'", ""));
	 				gr.setUsername(gr.getUsername().replace("\\", "/"));
	 			}
	 			if(!ComUtil.isEmpty(gr.getOrdercode())){
	 				gr.setOrdercode(gr.getOrdercode().substring(gr.getOrdercode().length()-4));
	 			}
	 			
	 			if(gr.getStatus()==1){
	 				gr.setIsaccpt(1);//原文中是gr.us(1)，isaccpt一个int类型好像没有撒用，就用来测试用
	 			}
	 			if(gr.getPrice()!=null){
	 				gr.setPrice(gr.getPrice().setScale(2,BigDecimal.ROUND_HALF_EVEN));
	 			}
	 		}
	 		
	 		 return gr;
	 	 }
	 	 /**
	 	  * 获取当前秒杀0秒杀未开启1--11:00——13:00 2秒杀1已结束秒杀2未开启3--20:00————22:00 4全部秒杀已结束
	 	  * **/
	 	public static Integer getKillType(){
	 		Date time=new Date();
	 		Calendar cal1=Calendar.getInstance();
	 		cal1.set(Calendar.HOUR_OF_DAY, 11);
	 		cal1.set(Calendar.MINUTE, 0);
	 		cal1.set(Calendar.SECOND, 0);
	 		Calendar cal2=Calendar.getInstance();
	 		cal2.set(Calendar.HOUR_OF_DAY, 13);
	 		cal2.set(Calendar.MINUTE, 0);
	 		cal2.set(Calendar.SECOND, 0);
	 		Calendar cal3=Calendar.getInstance();
	 		cal3.set(Calendar.HOUR_OF_DAY, 20);
	 		cal3.set(Calendar.MINUTE, 0);
	 		cal3.set(Calendar.SECOND, 0);
	 		Calendar cal4=Calendar.getInstance();
	 		cal4.set(Calendar.HOUR_OF_DAY, 22);
	 		cal4.set(Calendar.MINUTE, 0);
	 		cal4.set(Calendar.SECOND, 0);
	 		Integer type=0;
	 		if(time.before(cal1.getTime())){
	 			type=0;
	 		}else  if(time.before(cal2.getTime())&&time.after(cal1.getTime())){
	 			type=1;
	 		}else  if(time.before(cal3.getTime())&&time.after(cal2.getTime())){
	 			type=2;
	 		}else  if(time.before(cal4.getTime())&&time.after(cal3.getTime())){
	 			type=3;
	 		}else if(time.after(cal4.getTime())){
	 			type=4;
	 		}
			return type;
	 		
	 	}
	 	 /**
	 	  * 获取当前秒杀时间
	 	  * **/
	 	public static Date getKillTime(Integer type){
	 		 Calendar cal=Calendar.getInstance();
			 cal.set(Calendar.HOUR_OF_DAY, 11);
			 	cal.set(Calendar.MINUTE, 0);
		 		cal.set(Calendar.SECOND, 0);
			 if(type==0){
			 	cal.set(Calendar.HOUR_OF_DAY, 11);
			 }else  if(type==1){
				 cal.set(Calendar.HOUR_OF_DAY, 13);
			 }else  if(type==2){
				 cal.set(Calendar.HOUR_OF_DAY, 20);
			 }else  if(type==3){
				 cal.set(Calendar.HOUR_OF_DAY, 22);
			 }else  if(type==4){
				 cal.set(Calendar.HOUR_OF_DAY, 22);
			 }
			return cal.getTime();
	 		
	 	}
	 	
	 	 /**
	 	  * 获取时间
	 	  * **/
	 	public static Date getDate(String dateStr){
	 		 Calendar cal=Calendar.getInstance();
	 		Date date = null;
	 		if (!ComUtil.isEmpty(dateStr)) {
				try {
					date = sdf.parse(dateStr);
				} catch (ParseException e) {
					e.printStackTrace();
				}
			}
			return date;
	 		
	 	}
	 	 /**
	 	  * 获取当前限购状态
	 	  * **/
	 	public static boolean getGoodsStat(RunfastGoodsSell gs){
	 		 Calendar cal=Calendar.getInstance();
	 		boolean falg=false;
	 		if(gs!=null&&gs.getIslimited()!=null&&gs.getIslimited().equals(1)&&gs.getLimiendtime()!=null&&gs.getLimistarttime()!=null&&gs.getLimitnum()!=null&&gs.getLimitnum()>0){
	 			if(gs.getLimiendtime().after(new Date())&&gs.getLimistarttime().before(new Date())){
	 				falg=true;
	 			}
	 		}
			return falg;
	 		
	 	}
	/**
	 * 获取当前限购状态
	 * **/
	public static boolean getGoodsStat(RunfastGoodsSell gs, Date date){
		Calendar cal=Calendar.getInstance();
		boolean falg=false;
		if(gs!=null&&gs.getIslimited()!=null&&gs.getIslimited().equals(1)&&gs.getLimiendtime()!=null&&gs.getLimistarttime()!=null&&gs.getLimitnum()!=null&&gs.getLimitnum()>0){
			if(gs.getLimiendtime().after(date)&&gs.getLimistarttime().before(date)){
				falg=true;
			}
		}
		return falg;

	}
	 	 /**
	 	  * 获取当前秒杀时间
	 	  * **/
	 	public static Date getKillTime(){
	 		 Calendar cal=Calendar.getInstance();
	 		 Date date=null;
			  try {
				 date = sdf1.parse(sdf1.format(new Date()));
			} catch (ParseException e) {
				e.printStackTrace();
			}
			return date;
	 		
	 	}
	 	 /**
	 	  * 获取当前秒杀状态秒杀未开启1，2秒杀进行中 4秒杀已结束
	 	  * **/
	 	public static Integer getKillType(Date startTime,Date endTime){
	 		Date time=getKillTime();
	 		Integer type=-1;
	 		if(time.before(startTime)){
	 			type=1;
	 		}else  if(time.before(endTime)&&time.after(startTime)){
	 			type=2;
	 		}else if(time.after(endTime)){
	 			type=4;
	 		}
			return type;
	 		
	 	}
		 /**
		  * APP端根据经纬度获取百度位置
		  * @param log
		  * @param lat
		  * @param pois 是否显示周边  0：不显示 1：显示
	 	  * @return
		  */
		 public static List<Map<String, Object>> getAddAPP(Double log, Double lat ,int pois){  
			  	String res = "";
				String urlString = "http://api.map.baidu.com/geocoder/v2/" +
	    		"?ak="+ak2+"&callback=renderReverse&" +
	    		"location="+lat+","+log+"&output=json&pois="+pois;  
				
				List<Map<String, Object>> poisList = new ArrayList<Map<String,Object>>();
				try
				
				{
					HttpBase httpBase = new HttpBase(urlString);
					httpBase.get();
					httpBase.setCharset("UTF-8");
					
					res = httpBase.getResponseText();
					
				//使用http请求获取转换结果

				if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

					String str = res.substring(res.indexOf("(") + 1, res.length()-1);
					
		
					String err = res.substring(res.indexOf("status") + 8, res.indexOf("status") + 9);
					
					if ("0".equals(err)){
						
					
					
					//编码转换
					
						int start =0;
						int end = 0;	
						if(str.indexOf("pois")!=-1){
							start = str.indexOf("pois");
						}
						if(str.indexOf("]")!=-1){
							end = str.indexOf("]");
						}
						//System.out.println(str.substring(start+6, end+1));
						str = str.substring(start+6, end+1);//附近地址数组
						JSONArray jsonArray = new JSONArray(str);
						//String city =(String) ((JSONObject)jsonArray.get(i)).opt("city");
						for(int i=0 ;i<jsonArray.length(); i++){
							
							String name =(String) ((JSONObject)jsonArray.get(i)).opt("name");
							String addr =(String) ((JSONObject)jsonArray.get(i)).opt("addr");
							
							JSONObject obj = ((JSONObject)jsonArray.get(i)).optJSONObject("point");
							
							Double latitude = obj.getDouble("y");
							Double longitude =  obj.getDouble("x");
							
							//System.out.println(name +":"+addr +"longitude="+obj.get("x")+"latitude="+obj.get("y"));
							Map<String, Object> map = new HashMap<String, Object>();
							map.put("name", name);
							map.put("content", addr);
							map.put("latitude", latitude);
							map.put("longitude", longitude);
							
							poisList.add(map);
						}
						
					}

				}

				} catch (Exception e)

				{

				e.printStackTrace();

				}
				
		        return poisList;    
		    } 
			/**
			 *根据经纬度查询所在城市
			 */
		public static String selectcityAPP(Double log, Double lat ){
			String res = "";
			String sc ="";
			String urlString =  "http://api.map.baidu.com/geocoder/v2/?ak="+ak2+""
					+ "&location="+lat+","+log+"&output=json&pois=1";
			HttpBase httpBase = new HttpBase(urlString);
			httpBase.get();
			httpBase.setCharset("UTF-8");
			
			res = httpBase.getResponseText();
			if(res!=null){
				int start =0;
				int end = 0;
				if(res.indexOf("city")!=-1){
					start = res.indexOf("city");
				}
				if(res.indexOf("district")!=-1){
					end = res.indexOf("district");
				}
				 sc = res.substring(start+7,end-3);
			}
		
			return sc;
		}
		/**
		  *  根据关键字获取城市周边的地址、建筑物
		  * @param keyword 关键字
		  * @param area 地区 如：南宁
		  * @param pageSize 数量
		  * @param page 页数
		  * @return
		  */
		 public static List<Map<String, Object>> findByKeyAPP(String keyword, String area ,Integer pageSize , Integer page){  

			 	List<Map<String, Object>> list =new ArrayList<Map<String,Object>>();
			
		        String urlString = "http://api.map.baidu.com/place/search?query="+
							        keyword+"&page_size"+pageSize+"&page_num="+page+"&scope=1&region="+
							        area+"&output=json&ak="+ak2+"";  
		       
		        String res = "";     
		    	HttpBase httpBase = new HttpBase(urlString);
				httpBase.get();
				httpBase.setCharset("UTF-8");
				
				res = httpBase.getResponseText();
		        try {     
		        	 
					//使用http请求获取转换结果

				//	if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

						String err = res.substring(res.indexOf("status") + 9, res.indexOf("status") + 11);
						
						if ("OK".equals(err)){
							
						
						
							//编码转换
							
							int start =0;
							int end = 0;
							if(res.indexOf("results")!=-1){
								start = res.indexOf("results");
							}
							if(res.indexOf("]")!=-1){
								end = res.indexOf("]");
							}
						
							//System.out.println(res.substring(start+9, end+1));
							res = res.substring(start+9, end+1);//附近地址数组
							
							
						JSONArray jsonArray = new JSONArray(res);
							for(int i=0 ;i<jsonArray.length(); i++){
								
								String name =(String) ((JSONObject)jsonArray.get(i)).opt("name");
								String addr =(String) ((JSONObject)jsonArray.get(i)).opt("address");
								
								JSONObject obj = ((JSONObject)jsonArray.get(i)).optJSONObject("location");
								
								Double latitude = obj.getDouble("lat");
								Double longitude =  obj.getDouble("lng");
								
								
								Map<String, Object> map = new HashMap<String, Object>();
								map.put("name", name);
								map.put("content", addr);
								map.put("latitude", latitude);
								map.put("longitude", longitude);
								
								list.add(map);
							}
							
						}

					
		        	
		        	
		        } catch (Exception e) {    
		            System.out.println("error in wapaction,and e is " + e.getMessage());    
		        }   
		        
		        return list;    
		    }  
		 /**
		  * 根据经纬度获取百度位置
		  * @param log
		  * @param lat
	 	  * @return
		  */
		 public static Map<String, Object> getAddressAPP(Double log, Double lat ){  
			  	String res = "";
				String urlString = "http://api.map.baidu.com/geocoder/v2/" +
	    		"?ak="+ak2+"&callback=renderReverse&" +
	    		"location="+lat+","+log+"&output=json";  
				Map<String, Object> map = new HashMap<String,Object>();
				try
				
				{
					HttpBase httpBase = new HttpBase(urlString);
					httpBase.get();
					httpBase.setCharset("UTF-8");
					
					res = httpBase.getResponseText();
					
				//使用http请求获取转换结果

				if (res.indexOf("(") > 0 && res.indexOf(")") > 0){

					String str = res.substring(res.indexOf("(") + 1, res.length()-1);
					
		
					String err = res.substring(res.indexOf("status") + 8, res.indexOf("status") + 9);
					
					if ("0".equals(err)){
						
					
					
					//编码转换
						
						int start =0;
						int end = 0;
						if(res.indexOf("results")!=-1){
							start = res.indexOf("results");
						}
						if(res.indexOf("]")!=-1){
							end = res.indexOf("]");
						}
						//System.out.println(str.substring(start+6, end+1));
						//str = str.substring(start+6, end+1);//附近地址数组
						res = res.substring(start+9, end+1);//附近地址数组
						
						JSONObject json=new JSONObject(str);
						JSONObject jsonObj=json.getJSONObject("result");
						//JSONObject jsonObj = new JSONObject(str);
						
						//JSONObject poiRegions =(JSONObject) jsonObj.optJSONObject("poiRegions");
						JSONObject addressComponent =(JSONObject) jsonObj.optJSONObject("addressComponent");
						//String name=poiRegions.optString("name");
							//JSONObject addjsonObj = new JSONObject(addressComponent);
							String formatted_address =(String) jsonObj.optString("sematic_description");
							String province=(String)addressComponent.optString("province");
							//int leng=province.length();
							formatted_address=formatted_address.replace(province, "");
						
							String regex="(附近)";
							String regex2="(米)";
							Matcher matcher = Pattern.compile(regex).matcher(formatted_address);
							if(matcher.find()){
								int start1 = formatted_address.indexOf("附近");
								String address2=formatted_address.substring(start1);
								Pattern p = Pattern.compile(".*\\d+.*");
								Matcher m = p.matcher(address2);
								Matcher m2 = Pattern.compile(regex2).matcher(address2);
								if(m.matches()&&m2.find()){
									formatted_address=formatted_address.substring(0,start1);
									//System.out.println("formatted_address="+formatted_address);
								}
								
								
							} 
							String city=(String)addressComponent.optString("city");
							
							String district=(String)addressComponent.optString("district");
							//formatted_address=district+formatted_address;
							map.put("province", province);
							map.put("city", city);
							map.put("countyName", district);
							map.put("address", district);
							//map.put("name", name);
							map.put("latitude", lat);
							map.put("longitude", log);
					}

				}

				} catch (Exception e)

				{

				e.printStackTrace();

				}
				
		        return map;    
		    }
		 /**
			 *处理特殊‘符号
			 */
	 	 public static String replaceTag(String str){
	 		if(!ComUtil.isEmpty(str)){
	 			str=str.replace("'", "");
	 			str=str.replace("\\", "/");
 			}
			return str;
	 	 }
	 	 
	 	/**
			 * 时间 date 是否在date1 ，date2之间
			 * @param date
			 * @param beginTime
			 * @param endTime
			 * @return
			 */
			public static boolean inTime2(Date beginTime,Date endTime,Date date){
				
				boolean after = false;
				if(beginTime!=null&&endTime!=null&&date!=null&&date.after(beginTime)&&date.before(endTime)){
					after=true;
				}
				return after;
			}
			 /**
			 *处理APP商品描述中图片路径符号
			 */
	 	 public static String replaceimg(String context){
	 		if(!ComUtil.isEmpty(context)){
	 			//<p><img src="/upload/1486776927733_4176.png" style="float:none;" title="30.png" /></p><p><img src="/upload/1486776927968_6814.png" style="float:none;" title="31.png" /></p><p><img src="/upload/1486776928202_9245.png" style="float:none;" title="32.png" /></p><p><img src="/upload/1486776928624_3621.png" style="float:none;" title="33.png" /></p><p><img src="/upload/1486776929218_3469.png" style="float:none;" title="34.png" /></p><p><img src="/upload/1486776929733_3811.png" style="float:none;" title="35.png" /></p><p><img src="/upload/1486776931249_3152.png" style="float:none;" title="36.png" /></p><p><br /></p>
	 			context=context.replace("src=\"/upload", "src=\"http://www.gxptkc.com/upload");
 			}
			return context;
	 	 }
	 	 
	 	 /*
	      * 验证手机号码
	      * 
	      * */
	 	public static boolean isPhoneNumber(String tel){
	     	
	     	boolean flag=false;
	     	Pattern p=Pattern.compile("^1(3[0-9]|4[57]|5[0-9]|8[0-9]|70|77|75|76|78|73|9[0-9]|6[0-9])\\d{8}$");
	     	flag=p.matcher(tel).matches();
	     	return flag;
	     }
	 	 public static String replacenumber(String number){
		 		if(!ComUtil.isEmpty(number)){
		 			//<p><img src="/upload/1486776927733_4176.png" style="float:none;" title="30.png" /></p><p><img src="/upload/1486776927968_6814.png" style="float:none;" title="31.png" /></p><p><img src="/upload/1486776928202_9245.png" style="float:none;" title="32.png" /></p><p><img src="/upload/1486776928624_3621.png" style="float:none;" title="33.png" /></p><p><img src="/upload/1486776929218_3469.png" style="float:none;" title="34.png" /></p><p><img src="/upload/1486776929733_3811.png" style="float:none;" title="35.png" /></p><p><img src="/upload/1486776931249_3152.png" style="float:none;" title="36.png" /></p><p><br /></p>
		 			number=number.replace("１", "1");
		 			number=number.replace("２", "2");
		 			number=number.replace("３", "3");
		 			number=number.replace("４", "4");
		 			number=number.replace("５", "5");
		 			number=number.replace("６", "6");
		 			number=number.replace("７", "7");
		 			number=number.replace("８", "8");
		 			number=number.replace("９", "9");
		 			number=number.replace("０", "0");
		 			number=number.trim();
	 			}
				return number;
		 	 }
 
 /*
  * 把百度坐标转换成高德坐标
  * 
  * */
	 	 
	 	public static Map<String, Object> getGDlocFromBD(String log, String lat){  
	 		
	 		//http://restapi.amap.com/v3/assistant/coordinate/convert?key=f2d9f1f42e56a8e5ddf9b3a1b669f3b9&locations=30.590099,114.353658&coordsys=baidu
		  	String res = "";
			String urlString = "http://restapi.amap.com/v3/assistant/coordinate/convert" +
    		"?key="+gaoDekey+"&locations=" +log + "," +lat + "&coordsys=baidu";  
			Map<String, Object> map  = null;
			//List<Map<String, Object>> poisList = new ArrayList<Map<String,Object>>();
			try
			
			{
				HttpBase httpBase = new HttpBase(urlString);
				httpBase.get();
				httpBase.setCharset("UTF-8");
				
				res = httpBase.getResponseText();
				
			//使用http请求获取转换结果
				System.out.println("坐标转换值" + res);
				JSONObject json = new JSONObject(res);
				if(json.get("status").equals("1")){
					map = new HashMap<String, Object>();
					String[] arr=json.get("locations").toString().split(",");
					if(arr.length == 2){
						map.put("lng", arr[0]);
						map.put("lat", arr[1]);
					}
					else{
						System.out.println("数组长度 不读");
					}
					
				}else{
					System.out.println("转换坐标失败  信息："+ res);
				}
				

			} catch (Exception e)

			{

			e.printStackTrace();

			}
			
	        return map;    
	    }  
	 	
	 	
	 	
	 	
	 	 public static String sendGet(String url) {
	         String result = "";
	         BufferedReader in = null;
	         try {
	             String urlNameString = url;
	             URL realUrl = new URL(urlNameString);
	             // 打开和URL之间的连接
	             java.net.URLConnection connection = realUrl.openConnection();
	             // 设置通用的请求属性
	             connection.setRequestProperty("accept", "*/*");
	             connection.setRequestProperty("connection", "Keep-Alive");
	             connection.setRequestProperty("user-agent",
	                     "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
	             // 建立实际的连接
	             connection.connect();
	             // 获取所有响应头字段
	             Map<String, List<String>> map = connection.getHeaderFields();
	             // 遍历所有的响应头字段
	             for (String key : map.keySet()) {
	                 System.out.println(key + "--->" + map.get(key));
	             }
	             // 定义 BufferedReader输入流来读取URL的响应
	             in = new BufferedReader(new InputStreamReader(
	                     connection.getInputStream()));
	             String line;
	             while ((line = in.readLine()) != null) {
	                 result += line;
	             }
	         } catch (Exception e) {
	             System.out.println("发送GET请求出现异常！" + e);
	             e.printStackTrace();
	         }
	         // 使用finally块来关闭输入流
	         finally {
	             try {
	                 if (in != null) {
	                     in.close();
	                 }
	             } catch (Exception e2) {
	                 e2.printStackTrace();
	             }
	         }
	         return result;
	     }


	 	
	 	
	 	
public static Map<String, Object> getLocFromAddr(String  addr) throws UnsupportedEncodingException{  
	 		
	 		//http://restapi.amap.com/v3/geocode/geo?key=f2d9f1f42e56a8e5ddf9b3a1b669f3b9&address=武汉市武昌区武铁佳苑东区26栋&output=JSON
		  	String res = "";
		  	
		  	String urlCodeAddr = URLEncoder.encode(addr, "UTF-8");
		  	
			String urlString = "http://restapi.amap.com/v3/geocode/geo" +
    		"?key="+gaoDekey+"&address=" + urlCodeAddr + "&output=JSON";  
			Map<String, Object> map  = null;	  
			try
			
			{
				//System.out.println("url=" + urlString);
				
				HttpBase httpBase = new HttpBase(urlString);
				
				httpBase.get();
				httpBase.setCharset("UTF-8");
				res = httpBase.getResponseText();
				JSONObject json = new JSONObject(res);
				if(json.get("status").equals("1")){
					map = new HashMap<String, Object>();
					
					JSONArray jarr = json.getJSONArray("geocodes");
					//JSONObject temp= json.optJSONObject("geocodes");
					
					if(jarr.length() == 1)
					{
						String[] arr = jarr.getJSONObject(0).getString("location").toString().split(",");
						if(arr.length == 2){
							map.put("lng", arr[0]);
							map.put("lat", arr[1]);
						}
						else{
							System.out.println("数组长度 不读");
						}
					}
					else
					{
						System.out.println("数组长度不对。。。。。。。。。。" + jarr.length());
					}
					
				}else{
					System.out.println("转换坐标失败  信息："+ res);
				}
			} 
			catch (Exception e)
			{
				e.printStackTrace();
			}
			
	        return map;    
	    }  
	 	 
}
